import React, { Component } from 'react'
import axios from 'axios'

export default class App extends Component {
  //获取数据
  getData = () => {
    axios.get('http://localhost:3000/api1/students').then(
      response => { console.log(response.data, 'success') },
      error => { console.log('失败了', error) }
    )
  }
  getFood = () => {
    axios.get('http://localhost:3000/api2/foods').then(
      response => { console.log(response.data, 'successFoods') },
      error => { console.log('失败了', error) }
    )
  }
  //食物列表
  render () {
    return (
      <div>
        <button onClick={this.getData}>获取数据</button>
        <button onClick={this.getFood}>foodList</button>
      </div>
    )
  }
}
